import org.junit.jupiter.api.Test;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class PriceTest {

    @Test
    void testOrigalPrice(){
        List<Fruit> fruits=new ArrayList<>();
        //5斤苹果  1斤草莓
        Fruit apple=new Fruit(new BigDecimal(8),new BigDecimal(5));
        fruits.add(apple);
        Fruit strawberry=new Fruit(new BigDecimal(13),new BigDecimal(1));
        fruits.add(strawberry);
        SuperMarket superMarket=new SuperMarket(BigDecimal.ONE,new BigDecimal(Integer.MAX_VALUE),BigDecimal.ZERO );

        BigDecimal payPrice=superMarket.getTotalPrice(fruits);
        //8*5+1*13=53
        assertEquals(new BigDecimal(53).floatValue(), payPrice.floatValue());
    }
    @Test
    void testMoreFruitPrice(){
        List<Fruit> fruits=new ArrayList<>();
        //5斤苹果  1斤草莓 5斤芒果
        Fruit apple=new Fruit(new BigDecimal(8),new BigDecimal(5));
        fruits.add(apple);

        Fruit strawberry=new Fruit(new BigDecimal(13),new BigDecimal(1));
        fruits.add(strawberry);

        Fruit mango=new Fruit(new BigDecimal(20),new BigDecimal(5));
        fruits.add(mango);

        SuperMarket superMarket=new SuperMarket(BigDecimal.ONE,new BigDecimal(Integer.MAX_VALUE),BigDecimal.ZERO );

        BigDecimal payPrice=superMarket.getTotalPrice(fruits);
        //8*5+1*13+5*20=153
        assertEquals(new BigDecimal(153).floatValue(), payPrice.floatValue());
    }
    @Test
    void testDiscountPrice(){
        List<Fruit> fruits=new ArrayList<>();
        //5斤苹果  1斤草莓 5斤芒果
        Fruit apple=new Fruit(new BigDecimal(8),new BigDecimal(5));
        fruits.add(apple);

        Fruit strawberry=new Fruit(new BigDecimal(13),new BigDecimal(1));
        fruits.add(strawberry);

        Fruit mango=new Fruit(new BigDecimal(20),new BigDecimal(5));
        fruits.add(mango);

        SuperMarket superMarket=new SuperMarket(new BigDecimal("0.8"),new BigDecimal(Integer.MAX_VALUE),BigDecimal.ZERO );

        BigDecimal payPrice=superMarket.getTotalPrice(fruits);
        //8*5+1*13+5*20=153 0.8=122.4
        assertEquals(new BigDecimal(122.4).floatValue(), payPrice.floatValue());
    }
    @Test
    void testThresholdPrice(){
        List<Fruit> fruits=new ArrayList<>();
        //5斤苹果  1斤草莓 5斤芒果
        Fruit apple=new Fruit(new BigDecimal(8),new BigDecimal(5));
        fruits.add(apple);

        Fruit strawberry=new Fruit(new BigDecimal(13),new BigDecimal(1));
        fruits.add(strawberry);

        Fruit mango=new Fruit(new BigDecimal(20),new BigDecimal(5));
        fruits.add(mango);

        SuperMarket superMarket=new SuperMarket(new BigDecimal("0.8"),new BigDecimal(100),BigDecimal.TEN );

        BigDecimal payPrice=superMarket.getTotalPrice(fruits);
        //8*5+1*13+5*20=153 0.8=122.4-10=125.4
        assertEquals(new BigDecimal(112.4).floatValue(), payPrice.floatValue());
    }

}
